package com.shine.app.ui;

import android.content.Intent;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.shine.app.AppManager;
import com.shine.app.BaseActivity;
import com.shine.app.R;
import com.shine.app.commons.UIHelper;
import com.shine.app.inject.InjectView;
import com.shine.app.inject.Injector;

public class SlideContactActivity extends BaseActivity implements
		OnClickListener {
	@InjectView(R.id.head_back)
	private ImageView head_backImageView;
	@InjectView(R.id.head_seacher)
	private ImageView head_searchImageView;
	@InjectView(R.id.head_name)
	private TextView head_nameTextView;
	@InjectView(R.id.link)
	private TextView linkTextView;
	@InjectView(R.id.email)
	private TextView emailTextView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.slide_contact);
		Injector.get(this).inject();

		head_nameTextView.setText(R.string.set_contact);
		head_backImageView.setOnClickListener(this);
		head_searchImageView.setOnClickListener(this);
		emailTextView.setOnClickListener(this);
		linkTextView.setOnClickListener(this);
		linkTextView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {

		case R.id.head_back:
			AppManager.getAppManager().finishActivity();
			overridePendingTransition(R.anim.anim, R.anim.slide_out_down);
			break;

		case R.id.head_seacher:
			UIHelper.showHome(this);
			overridePendingTransition(R.anim.anim, R.anim.slide_out_down);
			break;

		case R.id.link:
			Intent intent = new Intent(this, SlideFeedbackActivity.class);
			intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
			this.startActivity(intent);
			overridePendingTransition(R.anim.slide_in_up, R.anim.anim);
			break;

		case R.id.email:
			Intent data = new Intent(Intent.ACTION_SENDTO);
			data.setData(Uri.parse("mailto:"
					+ emailTextView.getText().toString().trim()));
			this.startActivity(data);
			overridePendingTransition(R.anim.slide_in_up, R.anim.anim);
			break;

		default:
			break;
		}
	}
}
